//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#ifndef Green_PyLog_H
#define Green_PyLog_H

#include "pybind11/pybind11.h"

#include "Log.h"
#include "ThreadContext.h"

namespace py = pybind11;

namespace Green {

  PYBIND11_MODULE(Log, mod) {
    mod
      .def("trace",
        [](const std::string &rLogMessage) {
          LOG(trace) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("debug",
        [](const std::string &rLogMessage) {
          LOG(debug) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("info",
        [](const std::string &rLogMessage) {
          LOG(info) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("warn",
        [](const std::string &rLogMessage) {
          LOG(warn) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("error",
        [](const std::string &rLogMessage) {
          LOG(error) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("fail",
        [](const std::string &rLogMessage) {
          LOG(fail) << "Front-end error reported: " << rLogMessage << std::endl;
          FAIL("front-end-error-reported");
        },
        py::call_guard<ThreadContext>())
      .def("notice",
        [](const std::string &rLogMessage) {
          LOG(notice) << "Front-end: " << rLogMessage << std::endl;
        },
        py::call_guard<ThreadContext>())
      .def("noticeNoBlock",
        [](const std::string &rLogMessage) {
          LOG(notice) << "Front-end: " << rLogMessage << std::endl;
        }
        /* No call guard because only intended for special thread executor use case in between starting dispatcher and starting threads */)
      ;
  }

}

#endif  // Green_PyLog_H
